/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package orderProcessingProcess.model;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import orderProcessingProcess.util.MyCustomDateAdapter;

/**
 *
 * @author dreni
 */
@XmlRootElement(name="order")
public class Order {

    private String id;
    private Date orderDate;
    private Customer customer;
    private List<Item> items;

    public Order(String id, Date orderDate, ArrayList<Item> items, Customer customer)
    {
        this.id = id;
        this.orderDate = orderDate;
        this.items = items;
        this.customer = customer;
    }

    public Order() 
    {
        items = new ArrayList<Item>();
    }
    
    /**
	 * @return the id
	 */
    @XmlAttribute(name="order_id", required =true)
	public String getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(String id) {
		this.id = id;
	}

	/**
	 * @return the orderDate
	 */
    @XmlJavaTypeAdapter(MyCustomDateAdapter.class)
    @XmlElement(name="orderDate", required =true)
	public Date getOrderDate() {
		return orderDate;
	}

	/**
	 * @param orderDate the orderDate to set
	 */
	public void setOrderDate(Date orderDate) {
		this.orderDate = orderDate;
	}

	/**
	 * @return the customer
	 */
    @XmlElement(name="customer", required =true)
	public Customer getCustomer() {
		return customer;
	}

	/**
	 * @param customer the customer to set
	 */
	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	/**
	 * @return the items
	 */
    @XmlElement
	public List<Item> getItems() {
		return items;
	}

	/**
	 * @param items the items to set
	 */
	public void setItems(List<Item> items) {
		this.items = items;
	}

    @Override
    public boolean equals(Object obj) {
    	if(obj.getClass().equals(Order.class))
    	{
    		//if(this.id.equals(((Order)obj).getId()))
    			return true;
    	}
        return false;
    }

    @Override
    public int hashCode() {
        return this.id.hashCode();
    }

    
}
